Deadlock detection in distributed systems